package org.example.work3.gateway.util;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.http.HttpHeaders;


public class VersionUtils {

    private static final String VERSION_NAME = "version";

    public static String getVersion(ServiceInstance instance) {
        //通过实例元数据获取版本信息
        return instance.getMetadata().get(VERSION_NAME);
    }

    public static String getVersion(HttpHeaders headers) {
        //根据请求头获取版本信息
        return headers.getFirst(VERSION_NAME);
    }
}
